package gui.factory;
import iface.Modificator;

import javax.swing.DefaultListModel;
import javax.swing.JList;

/**
 * Factory class to build special {@link JList} objects.
 * 
 * @author Marcus Lindner
 * @author Joana Otetelisanu
 * 
 */
public final class SpecialSelectionListFactory {
	/**
	 * @param modEnum 
	 * @param <T> 
	 * @return  a new JList
	 * @wbp.factory
	 */
	public static <T extends Enum<T> & Modificator> JList createModifierJList(Class <T> modEnum) {
		final JList list = new JList();
		list.setModel(new DefaultListModel());
		final DefaultListModel model = (DefaultListModel)list.getModel();
		
		for(T mod : modEnum.getEnumConstants()){
		   model.addElement(mod);
		}
		
		return list;
	}
	
	/**
	 * @return a new JList with set default list model
	 * @wbp.factory
	 */
	public static  JList createModifierJList() {
		final JList list = new JList();
		list.setModel(new DefaultListModel());
		return list;
	}
}